<%@page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.ProblemBrowseCondition"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.action.BrowseProblemAction"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>

<%
{
BrowseProblemAction browseAction = ActionCreator.createBrowseProblemAction();
List<Problem> problemList = browseAction.browseProblems(request);
String pageStr = request.getParameter(Constants.REQUEST_PARAMETER_PAGE_NUM);
int currentPage = 1;
try {
	ProblemBrowseCondition theBrowseConditon = (ProblemBrowseCondition) session.getAttribute(Constants.SESSION_PROBLEM_CONDITION);
	if (theBrowseConditon != null && theBrowseConditon.getPageStr() != null) {
		currentPage = Integer.parseInt(theBrowseConditon.getPageStr());
	}
} catch (Exception e) {
}
try {
	currentPage = Integer.parseInt(pageStr);
} catch (Exception e) {
}
int totalNum = (Integer) request.getAttribute(Constants.DAO_RESULT_NUMBER);
Integer totalPage = 0;
if (totalNum % Constants.PAGE_SIZE == 0) {
	totalPage = totalNum / Constants.PAGE_SIZE;
} else {
	totalPage = totalNum / Constants.PAGE_SIZE + 1;
}
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;">
	<tr>
		<td width="2"  class="appbg">&nbsp;</td>
		<td width="85" class="appbg"><img src="images/trace.gif"  style="vertical-align:middle;"/>查询结果</td>
		<td width="229" class="appbg">&nbsp;</td>
		<td width="58" class="appbg">&nbsp;</td>
		<td width="84" class="appbg">&nbsp;</td>
		<td width="74" class="appbg">&nbsp;</td>
		<td class="appbg">&nbsp;</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td colspan="6" height="40">
			查询到<font color="#FF0000"><%=totalNum%></font>条记录，共<font color="#FF0000"><%=totalPage%></font>页。
			<span style="margin-left: 15px; color: red">
			<%
			if (currentPage > 1) {
			%>
			<a style="color: #FF0000" href="javascript:" onclick="browseOverallProblems(<%=currentPage-1%>)">【上一页】</a>
			<%
			}
			%>
			第<%=currentPage%>页
			<%
			if (problemList.size() >= Constants.PAGE_SIZE) {
			%>
			<a style="color: #FF0000" href="javascript:" onclick="browseOverallProblems(<%=currentPage+1%>)">【下一页】</a>
			<%
			}
			%>
			</span>
		</td>
	</tr>
	<tr>
		<td colspan="7">
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td width="5%" class="a_text2" align="center">发现人</td>
				<td class="a_text2" width="10%" height="30">作业部（业务中心）</td>
				<td class="a_text2" width="12%">装置</td>
				<td width="12%" class="a_text2">问题标题</td>
				<td width="17%" class="a_text2">发现问题内容</td>
				<td width="17%" class="a_text2">整改措施</td>
				<td width="10%" class="a_text2" align="center">填报日期</td>
				<td width="10%" class="a_text2" align="center">回复日期</td>
				<td width="7%" class="a_text2" align="center">查看</td>
			</tr>
			<%
				int row = 0;
						for (int i = 0; i < problemList.size(); i++) {
							Problem problem = problemList.get(i);
							row++;
							Integer problemType = problem.getProblemType();
							String targetPage = Problem.getTargetDetailedPageURL(problem, request.getContextPath());
			%>
			<tr>
				<td class="a_text3" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getWriteUserName()%></td>
				<td class="a_text3" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getDepartment1Name()%></td>
				<td class="a_text3" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getEquipmentName()%></td>
				<td class="a_text3" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getProblemTitle()%></td>
				<td class="a_text3" align="center" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getProblemContent(50)%></td>
				<td class="a_text3" align="center" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=problem.getProblemZhenggai(50)%></td>
				<td class="a_text3" align="center" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=Util.formatDate(problem.getWriteTime().getTime())%></td>
				<td class="a_text3" align="center" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%=(problem.getCloseTime() == null)? "&nbsp;" : Util.formatDate(problem.getCloseTime().getTime())%></td>
				<td class="a_text3" align="center" style="border-bottom:1px #E3E3E3 dashed;border-right:1px #E3E3E3 dashed; <%=(row % 2 == 1)? "background: #F8F8FF":"background: #DCDCDC"%>">
					<%
					String theColor = "red";
					if (problem.getProcessStatus() == Constants.PROBLEM_STATUS_CLOSE) {
						theColor = "black";
					} else if (problem.getProcessStatus() == Constants.PROBLEM_STATUS_PROVED) {
						theColor = "blue";
					}
					%>
					<a href="javascript:" onclick="loadPageSection('<%=targetPage%>', 'mainContentDiv', {id:<%=problem.getId()%>, fromPage:'yiban'}, true)"
					style="color: <%=theColor%>">详细内容</a></td>
			</tr>
			<%
			}
			%>
			</table>
		</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td colspan="6" height="40">
			查询到<font color="#FF0000"><%=totalNum%></font>条记录，共<font color="#FF0000"><%=totalPage%></font>页。
			<span style="margin-left: 15px; color: red">
			<%
			if (currentPage > 1) {
			%>
			<a style="color: #FF0000" href="javascript:" onclick="browseOverallProblems(<%=currentPage-1%>)">【上一页】</a>
			<%
			}
			%>
			第<%=currentPage%>页
			<%
			if (problemList.size() >= Constants.PAGE_SIZE) {
			%>
			<a style="color: #FF0000" href="javascript:" onclick="browseOverallProblems(<%=currentPage+1%>)">【下一页】</a>
			<%
			}
			%>
			</span>
		</td>
	</tr>
</table>
<%
}
%>